//
//  RegistrationNameCellViewModel.swift
//  PorscheRegistration
//
//  Created by Jinzhu Liu on 2023/11/16.
//

import Foundation
import Combine

protocol RegistrationNameCellViewModelInputType: RegistrationTextFieldCellViewModelInputType {
    
}

protocol RegistrationNameCellViewModelOutputType: RegistrationTitleCellViewModelOutputType,
                                                  RegistrationTextFieldCellViewModelOutputType {
    
}

protocol RegistrationNameCellViewModelType: RegistrationCellViewModelType {
    var input: RegistrationNameCellViewModelInputType { get }
    var output: RegistrationNameCellViewModelOutputType { get }
}

class RegistrationNameCellViewModel: ObservableObject,
                                     RegistrationNameCellViewModelType,
                                     RegistrationNameCellViewModelInputType {
    
    var input: RegistrationNameCellViewModelInputType { self }
    var output: RegistrationNameCellViewModelOutputType { self }
    
    var title: String
    var textFieldEnable: Bool = true
    @Published var textValue: String = ""
    
    init(title: String) {
        self.title = title
    }
}

extension RegistrationNameCellViewModel: RegistrationNameCellViewModelOutputType {
    var textValuePublisher: AnyPublisher<String, Never> {
        $textValue.eraseToAnyPublisher()
    }
}
